#!/bin/bash

function setup_tranquility() {
  echo_start "$1 ... ..."
  confirm_operate "install tranquility"
  if [ $? -eq 0 ]; then
    if [ -d $HYRENTMP_HOME ]; then rm -rf $HYRENTMP_HOME;fi
    mkdir_check $HYRENTMP_HOME
    unzip -d $HYRENTMP_HOME $XDIR/packages/tranquility.zip >/dev/null
    tar -zxf $HYRENTMP_HOME/tranquility/tranquility-distribution-0.8.0.tgz -C $HYRENTMP_HOME/tranquility
    rm -rf $HYRENTMP_HOME/tranquility/tranquility-distribution-0.8.0.tgz
    local value_Druidhosts=($HRS_DRUID_HOSTS)
    for i in ${value_Druidhosts[@]}; do
      ssh -o StrictHostKeyChecking=no $i "if [ -d $HRS_TRANQUILITY_HOME ]; then rm -rf $HRS_TRANQUILITY_HOME;fi"
      ssh -o StrictHostKeyChecking=no $i ""mkdir -p $HRS_TRANQUILITY_HOME" || { die "make tranquility_dir fail!"; }"
      scp -r  $HYRENTMP_HOME/tranquility/* $i:$HRS_TRANQUILITY_HOME >/dev/null
    done

    echo_passed "$1 done."
  else
    echo_passed "$1 SKIP"
  fi
}
